<div class="table-tools">
    <form class="form-inline" method="post" action="__URL__/rank" id="search_form"  role="form">
        <input type="hidden" name="pagenum" id="pagenum_hidden" value="{$page.pagenum}">
        <input type="hidden" name="count" value="{$recordcount}">
        <div class="form-group">
            <input type="text" name="user_id" value="{$user_id}" placeholder="请输入用户id">
            <button  type="button" onclick="gotoPage(0)">搜索</button>
        </div>
    </form>
    <p>1v1场次榜</p>
</div>

<table id="users-table" class="table table-striped table-hover table-condensed datatable">
    <thead>

    <tr id="user_{$log.id}">
        <th >排行</th>
        <th >用户ID</th>
        <th>昵称</th>
        <th>手机号</th>
        <th>总场次</th>
        <th>总胜场</th>

        <!--<th width="80px">排序</th>-->
    </tr>
    </thead>
    <tbody>
    <volist name="list" id="log">
        <tr>
            <!--<td width="50px"><input name='id[]' type="checkbox" value="{$log.id}" /></td>-->
            <td class="question-name">{$log.rank}</td>
            <td class="question-name">{$log.user_id}</td>
            <td class="question-name">{$log.nickname}</td>
            <td class="question-name">{$log.phone}</td>
            <td class="question-name">
                <input type="text" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                       onpaste="this.value=this.value.replace(/[^\d.]/g,'')"
                       onchange="ajaxUpdateField(this);" name="total_number" size="4" data-table="t_ranking"
                       data-id="{$log.id}" value="{$log.total_number}"/>
            </td>

            <td class="question-name">
                <input type="text" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                       onpaste="this.value=this.value.replace(/[^\d.]/g,'')"
                       onchange="ajaxUpdateField(this);" name="win_number" size="4" data-table="t_ranking"
                       data-id="{$log.id}" value="{$log.win_number}"/>
            </td>

            <!--<td width="80px"><input name="sort[{$log.id}]" class="sort-input" type="text" value="{$log.sort}" /></td>-->
        </tr>
    </volist>
    </tbody>
</table>
<nav style="float:right">
    <spen class="total">共 {$recordcount}条记录</spen>
    <div class="fr">
        <ul class="pagination">
            <eq name="page['pagenum']" value="1">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('1')">«</a></li>
            <foreach name="page.pagenums" item="vo">
                <eq name="page['pagenum']" value="$vo">
                    <li class="active"><a href="#">{$vo}</a></li>
                    <else/>
                    <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                </eq>
            </foreach>
            <eq name="page['pagenum']" value="$page.endPage">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
        </ul>
    </div>
</nav>
<!-- Modal -->
<div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body" id="hint_content">
            </div>
            <div class="modal-footer">
                <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="save-change" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/layer/layer.js"></script>
<script>

    function ajaxUpdateField(obj) {
        var table = $(obj).data('table');
        var id = $(obj).data('id');
        var field = $(obj).attr('name').replace(/field_/ig, ""); // 字段名字
        var value = $(obj).val();
        console.info(id);
        $.ajax({
            type: 'POST',
            data: {table: table, id: id, field: field, value: value},
            url: "__URL__/updateField",
            dataType: "json",
            success: function (data) {
                console.info(data);
//                $("#update_field").empty().append(data.message);
//                $("#my_update_field").modal();
            },
            error: function (data) {
                $(".am-modal-bd").empty().append("请求超时！");
                $("#my-alert").modal();
            }
        });
    }


    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('#search_form').submit();
    }
</script>